package com.sgcc.nfc.lock.data.remote.api

import com.sgcc.nfc.lock.core.network.ApiResponse
import com.sgcc.nfc.lock.data.remote.dto.region.RegionDto
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

interface RegionApi {

    @GET("/api/v1/region/tree")
    suspend fun getRegionTree(): ApiResponse<List<RegionDto>>

    @GET("/api/v1/region/children")
    suspend fun getChildren(
        @Query("parentId") parentId: Long?
    ): ApiResponse<List<RegionDto>>

    @POST("/api/v1/region/add")
    suspend fun createRegion(
        @Body request: RegionRequest
    ): ApiResponse<Unit>

    @PUT("/api/v1/region/edit/{regionId}")
    suspend fun updateRegion(
        @Path("regionId") regionId: Long,
        @Body request: RegionRequest
    ): ApiResponse<Unit>

    @DELETE("/api/v1/region/delete/{regionId}")
    suspend fun deleteRegion(
        @Path("regionId") regionId: Long
    ): ApiResponse<Unit>
}

data class RegionRequest(
    val regionName: String,
    val regionType: Int,
    val parentId: Long
)
